package steveshrader.budget.client.events;

import com.google.gwt.event.shared.EventBus;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerRegistration;

/**
 * An event to indicate an Expense has been modified...saved, changed or deleted
 */
public class ModifiedExpenseEvent extends GwtEvent<ModifiedExpenseEvent.Handler> {
  /**
   * Handles {@link SaveExpenseEvent}.
   */
  public interface Handler extends EventHandler {
    void onExpenseSaved(ModifiedExpenseEvent e);
  }

  public static final Type<Handler> TYPE = new Type<Handler>();

  public static HandlerRegistration register(EventBus eventBus, Handler handler) {
    return eventBus.addHandler(TYPE, handler);
  }

  public ModifiedExpenseEvent() {
  }
  
  @Override
  public Type<Handler> getAssociatedType() {
    return TYPE;
  }

  @Override
  protected void dispatch(Handler handler) {
    handler.onExpenseSaved(this);
  }
}
